
/***************************************************************************
 *   Copyright (C) 2009 by Bernhard Neuhofer   *
 *   mail@bneu.at   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


using namespace std;
#include "../tools/log.h"
#include "message.h"
#include <iostream>
#include <cstdlib>

 bool Message::isPositive()
{
	return _sign;
}

/**
 * Returns the timestamp of the message
 * @return double timestamp of the message
 */
 double Message::getTimestamp()
{
	return _timestamp;
}

/**
 * Returns the receiver of the message.
 * @return int receiver of the message
 */
unsigned int Message::getreceiver() const
{
	return _receiver;
}

/**
 * Returns the color of the message
 * @return bool
 */
bool Message::getColor()
{
	return _color;
}

/**
 * Sets the sign
 * @param sign The sign to set
 */
 void Message::setSign ( bool sign )
{
	_sign=sign;
}

/**
 * Sets the timestamp of the message (must be positive)
 * @param timestamp the timestamp to set
 */
 void Message::setTimestamp ( double timestamp )
{
	if ( timestamp<0.0 )
	{
		FILE_LOG(logERROR)<<"Message.setTimestamp: Error: Negative timestamp supplied"<<endl;
		exit ( 0 );
	}
	else
	{
		_timestamp=timestamp;
	};
}

/**
 * Sets the receiver of the message
 * @param receiver the id of the receiver LP
 */
 void Message::setReceiver ( int receiver )
{
	if ( receiver<0 )
	{
		FILE_LOG(logERROR)<<"Message.setReceiver: Error: Negative LP ID supplied"<<endl;
		exit ( 0 );
	}
	else
	{
		_receiver=receiver;
	}
}

/**
 * Sets the color
 * @param color Sets the color to the given Value (white==true)
 */
 void Message::setColor ( bool color )
{
	_color=color;
}

/**
 * Compare operator: Tests if ttwo messages are equal. If a subclass defines additional attributes it has to overwrite the <code>operator==</code> method and provide a adequate comparison.
 * @param other The message to compare to
 * @return Returns true if the messages are equal
 */
  bool Message::operator== ( const Message &other ) const
{

	return ( other.getreceiver() ==_receiver );/*&&
			         other.getTimestamp() ==getTimestamp() &&
			         other.isPositive() ==isPositive() );*/
}




